package syswifistatus

import (
	"time"

	"smartconn.cc/cubestruct/Service/rpchandle"
	"smartconn.cc/tosone/logstash"
)

/*
func init() {
	networkctrller.Init()
}
*/

var connectedEventUnRegister, disconnectedEventRegister func()
var cnt int64

// WifiStatusPublish define
func WifiStatusPublish() {
	//connectedEventUnRegister = networkctrller.ConnectedEventRegister(rpchandle.WifiOnReport)
	//disconnectedEventRegister = networkctrller.DisconnectedEventRegister(rpchandle.WifiOffReport)
	for {
		time.Sleep(time.Second * 1)
		remain := cnt % 2
		if remain == 0 {
			logstash.Info("wifi is on")
			rpchandle.WifiOnReport()
		}
		if remain == 1 {
			logstash.Info("wifi is off")
			rpchandle.WifiOffReport()
		}
		cnt++

	}
}

// WifiStatusUnpublish define
func WifiStatusUnpublish() {
	connectedEventUnRegister()
	disconnectedEventRegister()
}
